/*****************************************************************************
 *   Copyright 2005 Tim A Wang
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 *
 ****************************************************************************/
package com.jb.database.metamodel;

import java.sql.ResultSet;
import java.sql.SQLException;


public class Column extends BaseDatabaseEntity {
    String columnDef;
    String columnName;
    String isNullable;
    String remark;
    String scopeCatlog;
    String scopeSchema;
    String scopeTable;
    String tableCatalog;
    String tableName;
    String tableSchema;
    String typeName;
    boolean isBestRowIdentifier;
    boolean isPrimaryKey;
    int charOctetLength;
    int columnSize;
    int dataType;
    int decimalDigits;
    int ordinalPosition;
    int sqlDataType;
    int sqlDateTimeSub;
    short sourceDataType;


    boolean selected=false;
    /**
     * Sets Octet length for the column.
     * @param charOctetLength the octet length.
     */
    public void setCharOctetLength(int charOctetLength) {
        this.charOctetLength = charOctetLength;
    }
    /**
     * Returns octet length of the column.
     * @return the octet length.
     */
    public int getCharOctetLength() {
        return charOctetLength;
    }
    /**
     * Sets column definition.
     * @param columnDef the column definition name.
     */
    public void setColumnDef(String columnDef) {
        this.columnDef = columnDef;
    }
    /**
     * Returns column definition name.
     * @return column definition.
     */
    public String getColumnDef() {
        return columnDef;
    }
    /**
     * Sets column name.
     * @param columnName the column name.
     */
    public void setColumnName(String columnName) {
        this.columnName = columnName;
        this.setName(columnName);
    }
    /**
     * Gets column name.
     * @return column name.
     */
    public String getColumnName() {
        return columnName;
    }

    public void setColumnSize(int columnSize) {
        this.columnSize = columnSize;
    }

    public int getColumnSize() {
        return columnSize;
    }

    public void setDataType(int dataType) {
        this.dataType = dataType;
    }

    public int getDataType() {
        return dataType;
    }

    public void setDecimalDigits(int decimalDigits) {
        this.decimalDigits = decimalDigits;
    }

    public int getDecimalDigits() {
        return decimalDigits;
    }

    public void setIsNullable(String isNullable) {
        this.isNullable = isNullable;
    }

    public String getIsNullable() {
        return isNullable;
    }

    public void setOrdinalPosition(int ordinalPosition) {
        this.ordinalPosition = ordinalPosition;
    }

    public int getOrdinalPosition() {
        return ordinalPosition;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public String getRemark() {
        return remark;
    }

    public void setScopeCatlog(String scopeCatlog) {
        this.scopeCatlog = scopeCatlog;
    }

    public String getScopeCatlog() {
        return scopeCatlog;
    }

    public void setScopeSchema(String scopeSchema) {
        this.scopeSchema = scopeSchema;
    }

    public String getScopeSchema() {
        return scopeSchema;
    }

    public void setScopeTable(String scopeTable) {
        this.scopeTable = scopeTable;
    }

    public String getScopeTable() {
        return scopeTable;
    }

    public void setSourceDataType(short sourceDataType) {
        this.sourceDataType = sourceDataType;
    }

    public short getSourceDataType() {
        return sourceDataType;
    }

    public void setSqlDataType(int sqlDataType) {
        this.sqlDataType = sqlDataType;
    }

    public int getSqlDataType() {
        return sqlDataType;
    }

    public void setSqlDateTimeSub(int sqlDateTimeSub) {
        this.sqlDateTimeSub = sqlDateTimeSub;
    }

    public int getSqlDateTimeSub() {
        return sqlDateTimeSub;
    }

    public void setTableCatalog(String tableCatalog) {
        this.tableCatalog = tableCatalog;
    }

    public String getTableCatalog() {
        return tableCatalog;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    public String getTableName() {
        return tableName;
    }

    public void setTableSchema(String tableSchema) {
        this.tableSchema = tableSchema;
    }

    public String getTableSchema() {
        return tableSchema;
    }

    public void setTypeName(String typeName) {
        this.typeName = typeName;
    }

    public String getTypeName() {
        return typeName;
    }

    public void assign(ResultSet crs) throws SQLException {
        setColumnName(crs.getString(4));
        setDataType(crs.getInt(5));
        setTypeName(crs.getString(6));
        setColumnSize(crs.getInt(7));
        setDecimalDigits(crs.getInt(8));
        setRemark(crs.getString(9));
    }

    public void setSelected(boolean selected) {
        this.selected = selected;
    }

    public boolean isSelected() {
        return selected;
    }
}
